﻿/*
 * Stardust Software R&D Group Confidential
 * Project: Vesalius Image Annotation - Name as Salomay
 *
 * (C) Copyright Stardust Software R&D Group. 2013
 *
 * The source code for this program is not published or otherwise divested of 
 * its trade secrets
 */
 
 
/*
 * Antk Facade Object suppiles API for client code so outside framework developer
 * can use the Antk component easily
 * @author Cheng Li, Oct 15, 2013
 */
var Antk = function (iframe) {
	// iframe container in outside framework
	this.iframe = iframe;
	// Salomay application object
	this.application = this.iframe.contentWindow.Salomay.Application;
	// window object of iframe
	this.winObj = this.iframe.contentWindow;
	
	/**
	 * Initialize ANTK component from outside framework
	 **/
	this.initComponent = function(){
		this.winObj.init();
	}
	
	/**
	 * This function will be called by VESALIUS to display the component in desired location in mentioned Size. 
	 * @param nWidth - Value in pixels 
	 * @param nHeight - Value in Pixels
	 **/
	this.setComponentSize = function(nWidth, nHeight){
		this.iframe.height = nHeight;
		this.iframe.width = nWidth;
		this.winObj.session.set("COMPONENT_WIDTH", nWidth);
		this.winObj.session.set("COMPONENT_HEIGHT", nHeight);
	}
	
	/**
	 * This function sets the image path to be defined for background drawing
	 * @param httpPath - http image Path for drawing
	 * 
	 **/
	this.setImage = function(httpPath) {
		var image = new Image();
		image.src = httpPath;
		var self = this;
		image.onload = function() {
			self.application.renderCanvas({imageWidth: image.width, imageHeight: image.height, bkImg: httpPath});
		};
	}
	
}